﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.Entity;
using ClassLibrary.DAO;
using System.IO;

public partial class en_GetCodeImage : System.Web.UI.Page
{
    TblImagesDAO ImageDAO = new TblImagesDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session[Global.SESSION_LOGGED_USER] != null)
            {
                LoadIamge();
            }
            else
                Response.Redirect("~/en/Login.aspx");
            
            String strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
            //TextBox2.Text = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/") + "admin/img/images/150163D.png";
        }
    }

    private void LoadIamge()
    {
        string idImg = Request.QueryString["IdImg"];
        TblImages image = ImageDAO.GetImageByID(Convert.ToInt32(idImg));
        
        String strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
        string url = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/") +"Admin/img/images/" + image.ImageURL;
        txtCodeImg.Text = "<img src=\"" + url + "\"" + " alt=\"" + "code image \"" + " style=\"" + " border:0\"" + "/>";

    }
}
